import { createRouter, createWebHashHistory } from 'vue-router'
// import box from '@/router/modules/box'
// import togranary from '@/router/modules/togranary'
// import myname from '@/router/modules/name'
/* Layout */
import Layout from '@/layout'
// 导入通用提示
const defaultSettings = require('@/settings')

const routes = [
  {
    path: '/',
    component: Layout,
    redirect: '/box',
    title: 'three.js学习页面',
    children: [
      {
        path: '/box',
        name: 'HomeView',
        title: '旋转盒子',
        component: () => import('@/views/box'),
        meta: {
          title: '旋转盒子'
        }
      },
      {
        path: '/togranary',
        name: 'ToGranary',
        title: '数字粮仓',
        component: () => import('@/views/togranary'),
        meta: {
          title: '数字粮仓'
        }
      },
      {
        path: '/myname',
        name: 'MyName',
        title: '你的名字',
        component: () => import('@/views/name'),
        meta: {
          title: '你的名字'
        }
      }
    ]

  }

  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})
// 设置路由title
router.beforeEach((to, from, next) => {
  document.title = `${to.meta.title} - ${defaultSettings.title} `
  next()
})
export default router
export { routes }
